<template>
  <div class="city">
    <city-header></city-header>
    <city-search :cities="allCities"></city-search>
    <city-list :cities="allCities" :hot="hotCities" ></city-list>
    <city-alphabet :cities="allCities"></city-alphabet>
  </div>
</template>
<script>
import CityHeader from "./components/Header.vue";
import CitySearch from "./components/Search.vue";
import CityList from "./components/List.vue";
import CityAlphabet from "./components/Alphabet.vue";
import axios from "axios";
export default {
  name: "City",
  data() {
    return {
      allCities: {},
      hotCities: []
    };
  },
  components: {
    CityHeader,
    CitySearch,
    CityList,
    CityAlphabet
  },
  methods: {
    getCityInfo() {
      axios.get("/api/city.json").then(this.handleGetCityInfoSucc);
    },
    handleGetCityInfoSucc(res) {
      console.log("res:", res);
      res = res.data;
      if (res.ret && res.data) {
        const data =res.data;
        this.allCities=data.cities;
        this.hotCities=data.hotCities;
      }
    }
  },
  mounted() {
    this.getCityInfo();
  }
};
</script>
<style lang="stylus" scoped>
.city {
  background-color: #888;
}
</style>



